﻿$(function() {
	
	//=========== PicFocus ==========//
	
	if($('#player').length>0){$('#player').eol_picFocus();}
	if($('#player_samll').length>0){$('#player_samll').eol_picFocus();}
	if($('#adleft').length>0){$('#adleft').eol_adAutoPlay().eol_hoverImg({bigpic:true}).eol_closeBtn();}
	if($('#adright').length>0){$('#adright').eol_adAutoPlay().eol_hoverImg({bigpic:true}).eol_closeBtn();}
	if($('#small_adleft').length>0){$('#small_adleft').eol_adAutoPlay().eol_hoverImg({bigpic:true}).eol_closeBtn().eol_scrollAd();}
	if($('#small_adright').length>0){$('#small_adright').eol_adAutoPlay().eol_hoverImg({bigpic:true}).eol_closeBtn().eol_scrollAd();}
	
	//===== Navi Fold=========//
	
	    var tmp=null;
		var index=null;
		$('a.submenu').mouseover (function(){
			window.clearTimeout(tmp)
			index=$('a.submenu').index($(this));		
			$('.txt_nav').hide().eq(index).show();
		}).mouseleave(function(){
			tmp=window.setTimeout(function(){
			$('.txt_nav').hide();
			},200)
		})
		$('.txt_nav').mouseover (function(){
			window.clearTimeout(tmp);
			index=$('.txt_nav').index($(this));
			$('a.submenu').eq(index).addClass('current');
		}).mouseleave(function(){
			$(this).hide();
			$('a.submenu').removeClass('current');
		})
		

   //===== Check all checbboxes =====//
	
	$(".titleIcon input:checkbox").click(function() {
		var checkedStatus = this.checked;
		$("#checkAll tbody tr td:first-child input:checkbox").each(function() {
			this.checked = checkedStatus;
				if (checkedStatus == this.checked) {
					$(this).closest('.checker > span').removeClass('checked');
					$(this).closest('table tbody tr').removeClass('thisRow');
				}
				if (this.checked) {
					$(this).closest('.checker > span').addClass('checked');
					$(this).closest('table tbody tr').addClass('thisRow');
				}
		});
	});	
	
	$(function() {
    $('#checkAll tbody tr td:first-child input[type=checkbox]').change(function() {
        $(this).closest('tr').toggleClass("thisRow", this.checked);
		});
	});

    //===== Check all checbboxes 2=====//

	$("#selectAll").click(function () {//全选
            $(".message :checkbox").attr("checked", true);
			$(".message").addClass("messagecurrent");
        });

    $("#unSelect").click(function () {//全不选
            $(".message :checkbox").attr("checked", false);
			$(".message").removeClass("messagecurrent");
        });
	
	
	//搜索框
	var select_menu=$('.input_l.pos_r');
	select_menu.each(function(){
		var $this=$(this);
		$(this).bind('click',function(event){
			event.stopPropagation();
			var menu=$('.pos_a_l',$this);
			menu.show();
			var target=$(event.target);
			if(target.is('a')){
				$(this).find('div.selected').html(target.html());
				menu.hide();
				return false;
			}
			return false;
		});
		$(document).click(function(event){
			
			if($(event.target).attr("class")!="og_next"){
				$('.pos_a_l',$this).hide();
		    }
        }); 
		$(this).next().focus(function(){
			$('.pos_a_l',$this).hide();
		});
	});
	
	//===========folding provinces============//
	
		function unfoldMenu(pn, cn){
		var p = $('strong.menu-p'), c = $('div.menu-c'), cc = $('div.menu-c-current');
		
		if(cc.length==0){
			pn.addClass('menu-p-current');
			cn.show(500, function(){
				$(this).removeAttr('style').addClass('menu-c-current');
			});
		}else{
			for(i=0; i<cc.length; i++){
				if(cc[i].id==cn[0].id){
				  pn.removeClass('menu-p-current');
				  cn.hide(500, function(){
					$(this).removeAttr('style').removeClass('menu-c-current');
				});
				  break;
				}else{
					pn.addClass('menu-p-current');
					cn.show(500, function(){
						$(this).removeAttr('style').addClass('menu-c-current');
					});
				}
			}
			
		}

		}
	
	function menuHandle(){
		$('strong.menu-p').click(function(){
			var pn = $(this), cn = pn.next();
			unfoldMenu(pn, cn);
		});
	}
	

	menuHandle(); 
	
    //===========selector==================//
		
	$(".select_box input").click(function(){
		var thisinput=$(this);
		var thisul=$(this).parent().find("ul");
		if(thisul.css("display")=="none"){
			if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};
			thisul.fadeIn("100");
			thisul.hover(function(){},function(){thisul.fadeOut("100");})
			thisul.find("li").click(function(){thisinput.val($(this).text());thisul.fadeOut("100");}).hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});
			}
		else{
			thisul.fadeOut("fast");
			}
	})
	$("#submit").click(function(){
		var endinfo="";
		$(".select_box input:text").each(function(i){
			endinfo=endinfo+(i+1)+":"+$(this).val()+";\n";							 
		});						
		alert(endinfo);						
	})
	
	//===== jQuery Modal dialog =====//
	
    $('#dialog-modal').dialog({
		autoOpen: false, 
		width: 500,
		modal: true,
		buttons: {
				"同意并注册报名": function() {
					$( this ).dialog( "close" );
					$('#dialog-modal2').dialog( "open" );
				}
			}
		});
	$('#dialog-modal2').dialog({
		autoOpen: false, 
		width: 500,
		modal: true,
		buttons: {
				"关闭窗口": function() {
					$( this ).dialog( "close" );
				}
			}
		});
		
    $('#modal_open').click(function () {
        $('#dialog-modal').dialog('open');
        return false;
    });
 
    //=====teach dialog==============//
	
	$('.teacher-modal').dialog({
		autoOpen: false, 
		width: 500,
		modal: true,
		buttons: {
				"关闭": function() {
					$( this ).dialog( "close" );
				}
			}
		});
		
    $('.modal_open').click(function () {
        $('.teacher-modal').dialog('open');
        return false;
    });
	
    //=====Verification of mail dialog==============//
	
	$('#verifi-mail-modal').dialog({
		autoOpen: false, 
		width: 500,
		modal: true
		});
	
	/*		
    $('#verifi_mail_open').click(function () {
        $('#verifi-mail-modal').dialog('open');
        return false;
    });
	*/

	//=====Verification of phone dialog==============//
	
	$('#verifi-phone-modal').dialog({
		autoOpen: false, 
		width: 500,
		modal: true
		});
	/*	
    $('#verifi_phone_open').click(function () {
        $('#verifi-phone-modal').dialog('open');
        return false;
    });
	*/
	
	//===========Raty==================//
	if($('#default').length!=0)
    $('#default').raty({

           path:"images/stars/"

       });
});


